package controller;

import java.io.IOException;
import java.util.ArrayList;

import model.Grammar;
import model.User;

import org.zkforge.ckez.CKeditor;
import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Fileupload;
import org.zkoss.zul.Image;
import org.zkoss.zul.Textbox;

import com.sun.xml.internal.org.jvnet.fastinfoset.Vocabulary;

import util.FileUtils;

import admin.dao.GrammarDAO;
import admin.dao.UserDAO;
import admin.dao.VocabDAO;

public class AddVocaCtrl extends SelectorComposer<Component>{
	private static final long serialVersionUID = 1L;

	@Wire
    private Textbox txtName;
	
	@Wire
    private Textbox txtTitle;
	
	@Wire
    private CKeditor txtContent;
	
	
	@Listen("onClick = #btSubmit")
    public void submit(){
		VocabDAO.addVocab(new model.Vocabulary(txtName.getText(), txtTitle.getText(), txtContent.getValue()));
		Executions.getCurrent().sendRedirect("vocabularies_layout.jsp");
    }

}
